<?php
/**
 * Product Dao definition 
 *
 * @author guzhi
 * @since 2009-03-25
 */
 
require_once BaseUtil::getModulePath("base") . '/models/BaseDao.php';

class ProductDao extends BaseDao{

   protected $_name;

    public function  _setup() {
        $this->_name = $this->prefix() . "products";
        parent::_setup();
    }

    public function addProduct($product){
    	return $this->insertData($product);
    }
    
    public function updateProduct($id, $product){
    	$where =  $this->db_w->quoteInto('id = ?', $id);
    	$this->updateData($product, $where);
    }
    
    public function deleteProduct($id){
    	$isDel = array("is_delete"=>1);
    	$where =  $this->db_w->quoteInto('id = ?', $id);
    	$this->updateData($isDel, $where);
    }
    
    public function getProducts(){
        $select = $this->db_r->select();
        $select->from($this->_name,"*");
        $select->where("is_delete = 0");
        $sql = $select->__toString();
        $result = $this->db_r->fetchAll($sql);
        return $result;
    }
    
}